"""我们定义了一个与笔记相关的依赖关系."""
from typing_extensions import Annotated

from fastapi import Depends, Path

from core.models import Member, Memo

from api.v1.dependencies.member import get_current_member
from api.v1.models.memo import SendMemo
from api.v1.service.memo import MemoServiceAPI


def get_memo(
    service: Annotated[MemoServiceAPI, Depends()],
    member: Annotated[Member, Depends(get_current_member)],
    me_id: Annotated[int, Path(title="注意idi", description="注意idi")]
) -> Memo:
   
    return service.read_memo(me_id, member)


def validate_send_memo(
    memo_service: Annotated[MemoServiceAPI, Depends()],
    member: Annotated[Member, Depends(get_current_member)],
    data: SendMemo
):
    """发送便笺时验证必要的信息."""
    data.members = memo_service.get_receive_members(data.mb_ids)
    data.point = memo_service.calculate_send_point(member, len(data.members))

    return data
